package com.antler.smt.admin.service.impl;

import com.antler.smt.admin.mapper.PeopleInfoMapper;
import com.antler.smt.enums.ResultCodeEnum;
import com.antler.smt.request.admin.PeopleReq;
import com.antler.smt.response.admin.GetPeopleInfoResp;
import com.antler.smt.response.base.Result;
import com.antler.smt.service.admin.PeopleManageService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author zhangyi
 * @date 2018/9/27 17:55
 */
@Service
@Slf4j
public class PeopleManageServiceImpl implements PeopleManageService {

    @Autowired
    private PeopleInfoMapper peopleInfoMapper;

    /**
     * 分类查询人员信息
     *
     * @param peopleReq
     * @return
     */
    @Override
    public Result searchPeople(PeopleReq peopleReq) {
        Result result = null;
        Page<GetPeopleInfoResp> getPeopleInfoResps =
                peopleInfoMapper.searchPeople(peopleReq);
        if(getPeopleInfoResps != null){
            result = new Result(new PageInfo(getPeopleInfoResps));
        }else{
            result = new Result(ResultCodeEnum.QUERY_DATA_ERROR,"查询失败");
        }
        return result;
    }
}
